﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Core.Common;
using Core.Interfaces;
using Core.DataAccess;
using Core.DataAccess.IRepositories;
using Core.BusinessLogic.Interfaces;

namespace Core.BusinessLogic
{
    [Export(typeof(IWorkPlaceService))]
    public class WorkPlaceService : IWorkPlaceService
    {
        [Import]
        private IAccountRepository _accountRepository;
        [Import]
        private IWorkPlaceRepository _workPlaceRepository;

        public WorkPlaceService()
        {
            MEFManager.Compose(this);
        }

        public void SaveWorkPlace(WorkPlace wp)
        {
            _workPlaceRepository.SaveWorkPlace(wp);
        }

        public void SaveAccountWorkPlace(AccountWorkPlace awp)
        {
            _workPlaceRepository.SaveAccountWorkPlace(awp);
        }

        public List<WorkPlace> GetWorkPlaceListByAccountID(Int32 accountID)
        {
            return _workPlaceRepository.GetWorkPlaceListByAccountID(accountID);
        }

        public WorkPlace GetWorkPlaceByWPID(Int32 wpID)
        {
            return _workPlaceRepository.GetWorkPlaceByWPID(wpID);
        }

        public WorkPlace GetWorkPlaceByCompanyName(string companyName)
        {
            return _workPlaceRepository.GetWorkPlaceByWorkPlaceName(companyName);
        }

        public List<AccountWorkPlace> GetAccountWorkPlaceListByUsername(string username)
        {
            return _workPlaceRepository.GetAccountWorkPlaceListByUsername(username);
        }

        public List<AccountWorkPlace> GetAccountWorkPlaceListByAccountID(Int32 accountID)
        {
            return _workPlaceRepository.GetAccountWorkPlaceListByAccountID(accountID);
        }

        public List<Account> GetAllFriendsWorkplaceByAccountID(int accountID, string workplaceName)
        {
            return _workPlaceRepository.GetAllFriendsWorkplaceByAccountID(accountID, workplaceName);
        }

        public WorkPlace GetWorkPlaceByAccountID(int accountID)
        {
            return _workPlaceRepository.GetWorkPlaceByAccountID(accountID);
        }

        public int UpdateWorkPlaceInfo(int accountID, WorkPlace workplace)
        {
            return _workPlaceRepository.UpdateWorkPlaceInfo(accountID, workplace);
        }

        public int UpdateAccountWorkPlaceInfo(int accountID, AccountWorkPlace accWorkplace,int workplaceID)
        {
            return _workPlaceRepository.UpdateAccountWorkPlaceInfo(accountID, accWorkplace,workplaceID);
        }
    }
}
